import Cookies from 'js-cookie'

const TokenKey = 'vue_admin_template_token'

export function getToken() {
    // return Cookies.get(TokenKey)
    return sessionStorage.getItem(TokenKey)
}

/**
 * Sets the authentication token in session storage
 * @param {string} token - The token value to be stored
 * @returns {void} The result of setting the token in session storage
 */
export function setToken(token) {
    // return Cookies.set(TokenKey, token)
    return sessionStorage.setItem(TokenKey, token)
}

export function removeToken() {
    // return Cookies.remove(TokenKey)
    return sessionStorage.clear()
}

// 存储用户id
export function setUserId(userId) {
    return Cookies.set('userId', userId)
}

export function getUserId() {
    return Cookies.get('userId')
}

export function removeUserId() {
    return Cookies.remove('userId')
}

// sessionStorage清空
export function clearSession() {
    return sessionStorage.clear()
}

// 存储用户类型
export function getUserType() {
    // return Cookies.get(TokenKey)
    return sessionStorage.getItem('userType')
}

export function setUserType(userType) {
    // return Cookies.set(TokenKey, token)
    return sessionStorage.setItem('userType', userType)
}